﻿//出货单子打印
//作者:喻涛林 2009.2
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Comod_DrawPrint : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                ZSql zs = new ZSql();
                string strTable = "";
                string sql = "SELECT * FROM (SELECT stockId, ComodBarcode,Content,typeStock, ProcNum,WarehouseId,EditUserName,CONVERT(char(10),EditDate,120) as EditDate, CONVERT(char(10), storageTime, 120) AS storageTime, AuditState,(select isnull(sum(ProcNum),0) from CS_Stock where WarehouseId=a.WarehouseId and ComodBarcode=a.comodBarcode) as countNum,(select isnull(sum(number),0) from CS_Sales where ComodBarcode=a.comodBarcode and WarehouseId=a.WarehouseId) as saleNum,((select isnull(sum(ProcNum),0) from CS_Stock where WarehouseId=a.WarehouseId and ComodBarcode=a.comodBarcode) -(select isnull(sum(number),0) from CS_Sales where ComodBarcode=a.comodBarcode and WarehouseId=a.WarehouseId)) as StockNum, (SELECT WarehouseName FROM CS_Warehouse   WHERE WarehouseId = a.WarehouseId) AS WarehouseName,(SELECT WarehouseName FROM CS_Warehouse   WHERE WarehouseId = a.OldWarehouseId) AS OldWarehouseName, (SELECT Supplier FROM CS_Supplier WHERE SupplierId = a.SupplierId) AS SupplierName, (SELECT Brand  FROM Brand WHERE BrandId = a.BrandId) AS BrandName, (SELECT ComoditiesName FROM ComoditiesName  WHERE ComoditiesNameId = a.ComoditiesName) AS ComoditiesName, (SELECT Specifications FROM Specifications    WHERE SpecificationsId = a.ModelId) AS SpecificationsName, (SELECT Units FROM Units  WHERE UnitsId = a.UnitId) AS UnitsName, (SELECT ComoditiesType   FROM ComoditiesType    WHERE TypeId = a.ComoditiesType) AS ComoditiesTypeName FROM CS_Stock a ) Stock where stockId=" + Request.QueryString["id"] + " ORDER BY stockId DESC";
                zs.Open(sql);
                if (zs.Rows.Count > 0)
                {
                    strTable += "<table width=\"97%\"  border=\"0\"><tr><td class=\"F_size18 F_B\" align=\"center\">重庆市南川区协和家电有限公司</td></tr>";
                    strTable += "<tr><td  height=40  class=\"F_size16 F_B \" align=\"center\">商品配送单</td></tr></table>";

                    strTable += "<table width=\"97%\" align=\"center\" border=\"1\">";
                    strTable += "<tr><td width=\"33%\" height=\"27\">型号编号：" + zs.m_table.Rows[0]["ComodBarcode"].ToString() + "</td><td width=\"33%\">规格型号：" + zs.m_table.Rows[0]["SpecificationsName"].ToString() + "</td><td>所属类型： " + zs.m_table.Rows[0]["ComoditiesTypeName"].ToString() + "</td></tr>";
                    strTable += "<tr><td width=\"33%\" height=\"27\">商品名称："+ zs.m_table.Rows[0]["ComoditiesName"].ToString() +"</td><td width=\"33%\">品　　牌："+ zs.m_table.Rows[0]["BrandName"].ToString() +"</td><td>入库类型： "+ zs.m_table.Rows[0]["typeStock"].ToString() +"</td></tr>";
                    strTable += "<tr><td width=\"33%\" height=\"27\">原 仓 库："+ zs.m_table.Rows[0]["OldWarehouseName"].ToString() +"</td><td width=\"33%\">供 货 商："+ zs.m_table.Rows[0]["SupplierName"].ToString() +"</td><td>商品备注： "+ zs.m_table.Rows[0]["Content"].ToString() +"</td></tr>";
                    strTable += "<tr><td width=\"33%\" height=\"27\">转到仓库："+ zs.m_table.Rows[0]["WarehouseName"].ToString() +"</td><td width=\"33%\">转库数量："+ zs.m_table.Rows[0]["ProcNum"].ToString() +"</td><td>单　　位： "+ zs.m_table.Rows[0]["UnitsName"].ToString() +"</td></tr>";
                    strTable += "</table>";
                    
                        strTable += "<table width=\"97%\" border=\"0\"  align=\"center\"><tr><td colspan=\"4\"><font color=\"#FF0000\"><p>请您仔细核对商品型号、数量、金额是否一致。白色存根联、红色用户联。(用户签字有效)</p></font></td></tr><tr><td width=\"22%\" align=\"left\">开票人：" + zs.m_table.Rows[0]["EditUserName"].ToString() + "</td><td width=\"22%\" align=\"left\">时间：" + zs.m_table.Rows[0]["EditDate"].ToString() + "</td> <td width=\"22%\" align=\"left\">库房签字：</td> <td align=\"left\">备注：</td></tr></table>";

                }
                zs.Close();
                lblTable.Text = strTable;
            }
        }
    }
}
